package com.pn.warehouse.controller;

import com.pn.warehouse.entity.InStore;
import com.pn.warehouse.entity.Result;
import com.pn.warehouse.entity.Store;
import com.pn.warehouse.page.Page;
import com.pn.warehouse.service.InStoreService;
import com.pn.warehouse.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/instore")
@RestController
public class InStoreController {

    @Autowired
    private InStoreService inStoreService;

    @Autowired
    private StoreService storeService;

    /**
     * 查询所有的仓库
     */
    @RequestMapping("/store-list")
    public Result storeList(){
        //1、执行业务并返回
        List<Store> allStore = storeService.findAllStore();
        return Result.ok(allStore);
    }

    /**
     * 分页查询入库单
     */
    @RequestMapping("/instore-page-list")
    public Result inStoreListPage(Page page, InStore inStore){
        //1、执行业务并返回
        page = inStoreService.queryInStorePage(page, inStore);
        return Result.ok(page);
    }

    /**
     * 确认入库
     */
    @RequestMapping("/instore-confirm")
    public Result confirmInStore(@RequestBody InStore inStore){
        //1、执行业务并返回
        Result result = inStoreService.inStoreConfirm(inStore);
        return result;
    }

}
